package 错题;

import java.util.Arrays;

public class Problem01 {
    public static void injectionSort(int[] number){
        for(int j = 1;j<3;j++){
            int tmp = number[j];//tmp = 298 index = 1;
            int i = j-1;//i = 0
            while (tmp<number[i]){//number[j] < number[j-1]
                number[i+1] = number[i];//number[1] = 314,换到后面去操作
                i--;// i = -1
                if(i == -1)break;
            }
            number[i+1] = tmp;//index = 0, number[0] = 298
        }
    }
    public static void main(String[] args) {
        int[] arrays = {314,298,508,123,486,145};
        Problem01.injectionSort(arrays);
        System.out.println(Arrays.toString(arrays));
    }
}
